<template>
	<view class="code flex_c">
		<navBar title="邀请员工" color="#FFF" bg="#FD2B54"></navBar>
		<view style="height: 60rpx;">

		</view>
		<view class="content flex_c">
			<text>我的专属二维码</text>
			<image :src="store.store_qr" mode="aspectFill" class="code_qr"></image>
			<!-- <image class="code_logo" :src="$util.prefix('store/code_logo.png')"></image> -->
			<image class="code_logo" :src="$util.prefix('index/logo.png')"></image>
		</view>

		<view class="btn_down" @click="$native.downLoadImage(store.store_qr)">保存二维码</view>

		<view class="btn_box flex_r_between">
			<view class="btn_btn1" @click="$util.back()">返回</view>
			<view class="btn_btn2" @click="$native.toShareImage(store.store_qr)">分享到微信</view>
		</view>

	</view>
</template>

<script>
	import navBar from '@//compentents/navBar/navBar.vue';
	export default {
		components: {
			navBar,
		},
		data() {
			return {
				user: {},
				store: {
					store_qr: '',
				},
			}
		},
		methods: {
			downLoadCode() {
				uni.downloadFile({
					url: this.store.store_qr,
					success: (res) => {
						var oA = document.createElement('a');
						oA.download = '邀请二维码';
						oA.href = res.tempFilePath;
						document.body.appendChild(oA);
						oA.click();
						oA.remove();
					},
					fail: (err) => {
						this.$util.msg(`下载失败${err.errCode} -- ${err.errMsg}`);
					}
				});
			},
			
			getDetail(){
				this.$get('/store/getStoreInfo',{
					store_id: this.user.store_id
				}).then(res=>{
					this.store = res.data;
				})
			},
		},

		onLoad() {
			this.user = uni.getStorageSync('user');
			this.getDetail();
		},
	}
</script>

<style lang="less" scoped>
	.code {
		min-height: 100vh;
		background: url('https://qiniu-cdn.maeiyun.com//h5static/store/code_bg.png') 0 0 no-repeat;
		background-size: 100%;
		padding-bottom: 30rpx;
		background-color: #FD2D50;
	}

	.content {
		width: 640rpx;
		height: 886rpx;
		background: url('https://qiniu-cdn.maeiyun.com//h5static/store/code_bg_little.png') 0 0 no-repeat;
		background-size: 100%;
		margin: 0 54rpx 0;
		padding-top: 14rpx;

		text {
			font-weight: 600;
			font-size: 32rpx;
			color: #FFFFFF;
			line-height: 44rpx;
		}

		.code_qr {
			width: 360rpx;
			height: 360rpx;
			margin-top: 140rpx;
		}

		.code_logo {
			width: 216rpx;
			height: 70rpx;
			margin-top: 140rpx;
		}
	}

	.btn_down {
		width: 560rpx;
		height: 96rpx;
		background: linear-gradient(165deg, #EA0B37 0%, #CC0747 100%);
		border-radius: 48rpx;
		font-weight: 600;
		font-size: 32rpx;
		color: #FFFFFF;
		line-height: 96rpx;
		text-align: center;
		margin-top: 72rpx;
	}

	.btn_box {
		width: 560rpx;
		margin-top: 28rpx;

		.btn_btn1 {
			width: 200rpx;
			height: 96rpx;
			background: rgba(255, 255, 255, 0.4);
			border-radius: 48rpx;
			font-size: 32rpx;
			color: #84001A;
			line-height: 96rpx;
			text-align: center;
		}

		.btn_btn2 {
			width: 344rpx;
			height: 96rpx;
			background: rgba(255, 255, 255, 0.4);
			border-radius: 48rpx;
			font-size: 32rpx;
			color: #84001A;
			line-height: 96rpx;
			text-align: center;
		}
	}
</style>